<?php
/**
  * Mar 5, 2008
  *
  * Coded by: Ropu
  *
  */

//$hacker = new Hacker();

$id = "199513993";
$network = "Hi5";
$api_key = "a3694_dc769c190b8c9dd7aa8b2";
$Hi5AuthToken = 'PwlT6sKjzxb7K6GMl4RCBw..:WHtWIcTrs9nZ2HDu44YDOZmPQfCqhWFIQ2lzv55ajgGrVFAb0b2SUOqF5mw00fztVMSRdHEd-IXBpmkDDHBPufu2aXq7Yq3ib9qmqWRWgJw.';

$sid = "ropu es el mas capo";

include 'login.php';
echo "<xmp>";
//$hi5Auth = new Hi5Auth($api_key, $id, $Hi5AuthToken);
//$Hi5AuthToken = (string) new SimpleXMLElement($hi5Auth->plain('rovagnati@gmail.com', 'i430fx'));

//print_r($hacker);
//die;
//
  $hi5 = new Hi5Profile($api_key, $id, $Hi5AuthToken);
	$user = new SimpleXMLElement($hi5->foaf(), null, null, 'foaf', true);
//	
	$p = $user->Person;
	echo $p->nick;
	echo $p->givenName;
	echo $p->surName;
	echo $p->img->attributes()->resource;
	print_r($p->img->attributes()->resource);
	print_r($p);
	die;
////		
////  echo $user->city;
////  echo $user->email;
//	
//  $_SESSION['os'] = new OpenSocial($id, $network);
//  $hacker = $_SESSION['os']->getHacker();
////	$hacker = new Hacker();
//  
//  $hacker->setHackathon(1);
//  $hacker->setNickname(@$user->first_name . " " . @$user->last_name);
//  $hacker->setExtraInfo('City: ' . @$user->city . "\n" . @$user->interests);
//  $hacker->setName(@$user->first_name . " " . @$user->last_name);
//  $hacker->setEmail(@$user->email);
//  $hacker->save();


print_r($_SESSION);
die;
$hi5Auth = new Hi5Auth($api_key, $id, $Hi5AuthToken);
$Hi5AuthToken = (string) new SimpleXMLElement($hi5Auth->plain('rovagnati@gmail.com', 'i430fx'));

var_dump($hi5Auth->validateSession());
die;
$token = new SimpleXMLElement($hi5Auth->decodeToken(), null, null, 'hi5', true);
print_r((string)$token->attributes()->userId);
die;
//$hi5Test = new Hi5Test();
//$xml_data2 = $hi5Test->auth($Hi5AuthToken, 'hola ropu');
//
//$xml2 = new SimpleXMLElement($xml_data2);
//$rta = $xml2->xpath('//hi5:message');
//
//if($rta[0] != 'hola ropu') {
//  throw new Exception('wrong token');
//}

//$hi5Profile = new Hi5Profile($api_key, $id, $Hi5AuthToken);
//
////print_r($hi5Profile);
//
//$user = new SimpleXMLElement($hi5Profile->user(), null, null, 'hi5', true);
//
////$city = $user->xpath('//hi5:city');
//
//echo $user->city;
//echo $user->email;

$hi5Feed = new Hi5Feed($api_key, $id, $Hi5AuthToken);
$friends = new SimpleXMLElement($hi5Feed->photosFriends('23777773', 1, 1), null, null, 'hi5', true);
//foreach ($city->children() as $x) {
//  var_dump($x);
//}